<template>
  <div>
     <BreakSpace label="查询首保权益" :containerStyle="{ marginBottom: '10px' }"></BreakSpace>
    <TopFilter :list="topFilterList" labelWidth="85" @filterChange="changeHandle"></TopFilter>
       
        <FilterTable
          ref="table"
          :isSelectColumn="false"
          columnsRef="querySBQYmodel"
          :columns="columns"
          :loading="loading"
          :dataSource="sbqyDataList"
          :isMemoryPagination="true"
          :pageSize="20"
          :onColumnsChange="columns => (this.columns = columns)"
        >
        </FilterTable>
      </div>

</template>

<script>
// @author:@刘诗文
import { dictionary } from '@/utils/dictMixin';
import { authority } from '@/utils/authMixin';
import { notifyAction, confirmAction } from '@/utils';
import dictCode from '@/utils/dictCode';
import { querySBQX } from '@/api/repair/repairReception/customer';
export default {
  name: 'contactsPanel',
  components: {},
  mixins: [dictionary, authority],
  data() {
    return {
      topFilterList: this.createTopFilterList(),
      columns: this.createTableColumns(),
      sbqyDataList: [],
      loading: false
    };
  },
  mounted() {

  },
  methods: {

    createTableColumns() {
      return [
        {
          title: '序号',
          dataIndex: 'index',
          width: 70,
          sorter: true,
          render: props => {
            return <span>{props.row.index + 1}</span>;
          }
        },
        {
          title: '底盘号',
          dataIndex: 'VIN',
          sorter: true,
          filter: true,
          showOverflowTooltip: true,
          filterType: 'input'
        },
        {
          title: '是否有首保权益',
          dataIndex: 'SBQY',
          sorter: true,
          filter: true,
          showOverflowTooltip: true,
          filterType: 'input',
          filterItems: [
            { value:'N',text:'否' },
            { value:'Y',text:'是' }
          ],
          editItems: [
            { value:'N',text:'否' },
            { value:'Y',text:'是' }
          ],
          itemList:[
            { value:'N',text:'否' },
            { value:'Y',text:'是' }
          ]
        },

        {
          title: '使用情况',
          dataIndex: 'SYQK',
          sorter: true,
          filter: true,
          showOverflowTooltip: true,
          filterType: 'input',
          filterItems: [
            { value:'N',text:'否' },
            { value:'Y',text:'是' }
          ],
          editItems: [
            { value:'N',text:'否' },
            { value:'Y',text:'是' }
          ],
          itemList:[
            { value:'N',text:'否' },
            { value:'Y',text:'是' }
          ]
        },
        {
          title: '质量担保日期',
          dataIndex: 'WRDAT',
          width: 150,
          dateFormat: 'yyyy-MM-dd HH:mm:ss',
          sorter: true,
          filter: true,
          showOverflowTooltip: true,
          filterType: 'date-range',
          editable: false,
          editType: 'date-picker'
        }
      ];
    },
   
    createTopFilterList() {
      return [
         {
          type: 'INPUT',
          label: '底盘号',
          fieldName: 'VIN',
          placeholder: '请输入...',
          rules: [{ required: true, message: '请输入17位VIN号', trigger: 'blur' }]

        }
      ];
    },

    // 查询首保权益
    async changeHandle(){
      var params = {}; 
      
      params.VIN = this.topFilterList.find(x => x.fieldName === 'VIN').initialValue;
      const res = await querySBQX(params);
      if(res.resultCode == '200'){

        this.sbqyDataList = res.data;
      }
      
    },

  }
};
</script>

<style lang="less" scoped></style>
